package com.atguigu.srb.core.service.impl;

import com.atguigu.service.base.utils.JwtUtils;
import com.atguigu.srb.core.pojo.entity.TransFlow;
import com.atguigu.srb.core.mapper.TransFlowMapper;
import com.atguigu.srb.core.service.TransFlowService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 交易流水表 服务实现类
 * </p>
 *
 * @author Atguigu
 * @since 2022-11-19
 */
@Service
public class TransFlowServiceImpl extends ServiceImpl<TransFlowMapper, TransFlow> implements TransFlowService {

    @Override
    public List<TransFlow> tranflows(String token) {
        Long userId = JwtUtils.getUserId(token);
        return this.list(Wrappers.lambdaQuery(TransFlow.class)
                .eq(TransFlow::getUserId , userId)
                .eq(TransFlow::getStatus,1)
                .orderByDesc(TransFlow::getCreateTime));
    }
}
